package com.atguigu.realtime.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;

/**
 * @ClassName: MyTimeUtil
 * @Description:
 * @Author: kele
 * @Date: 2021/4/23 13:33
 **/
public class MyTimeUtil {

    public static Long TransfromTs (String birthday, String type){

        try {
            return new SimpleDateFormat(type).parse(birthday).getTime();
        } catch (ParseException e) {
            e.printStackTrace();
        }

        return null;
    }


    public static Long TransfromTs (String birthday) {
        String type = "yyyy-MM-dd HH:mm:ss";

        return TransfromTs(birthday, type);
    }

    public static String DateTransfrom (Long ts) {

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        return sdf.format(ts);
    }

}
